local extension = Package:new("tshu_token", Package.CardPack)
extension.extensionName = "tshu"
extension.game_modes_whitelist = {"tshu_mode","tgong_mode","lzhou_mode"}
Fk:loadTranslationTable{
  ["tshu_token"] = "天书衍生牌",
}

local U = require "packages/utility/utility"


  local crossbowAudio = fk.CreateTriggerSkill{
    name = "#tshu__crossbowAudio",
    refresh_events = {fk.CardUsing},
    can_refresh = function(self, event, target, player, data)
      return target == player and player:hasSkill(self) and player.phase == Player.Play and
        data.card.trueName == "slash" and player:usedCardTimes("slash", Player.HistoryPhase) > 1 and player:usedCardTimes("slash", Player.HistoryPhase) <= 5
    end,
    on_refresh = function(self, event, target, player, data)
      local room = player.room
      room:broadcastPlaySound("./packages/standard_cards/audio/card/crossbow")
      room:setEmotion(player, "./packages/standard_cards/image/anim/crossbow")
      room:sendLog{
        type = "#InvokeSkill",
        from = player.id,
        arg = "tshu__crossbow",
      }
    end,
  }
  local crossbowSkill = fk.CreateTargetModSkill{
    name = "#tshu__crossbow_skill",
    attached_equip = "tshu__crossbow",
    residue_func = function(self, player, skill, scope)
      if player:hasSkill(self) and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
        return 3
      end
    end,
  }
  crossbowSkill:addRelatedSkill(crossbowAudio)
  Fk:addSkill(crossbowSkill)
  
  local crossbow = fk.CreateWeapon{
    name = "tshu__crossbow",
    suit = Card.Club,
    number = 1,
    attack_range = 1,
    equip_skill = crossbowSkill,
  }
  
  extension:addCards({
    crossbow:clone(Card.Club,1),
    crossbow:clone(Card.Diamond, 1),
    crossbow:clone(Card.Spade, 1),
    crossbow:clone(Card.Heart, 1),
  })
  Fk:loadTranslationTable{
  ["tshu__crossbow"] = "连弩",
  [":tshu__crossbow"] = "装备牌·武器<br /><b>攻击范围</b>：１<br /><b>武器技能</b>：锁定技，出牌阶段你可以多使用3张【杀】。",
  ["#tshu__crossbow_skill"] = "连弩",
  }
  
  return extension